<?php
if(!empty($_POST) AND !isset($_POST['Entry']))
{
	$con = Connect();
	$last = mysql_fetch_assoc(mysql_query("SELECT * FROM notes WHERE ID='".$_SESSION['ID']."' ORDER BY Entry DESC"));
	if(!$last)
	{
		mysql_query("INSERT INTO notes (ID, Entry, Title, Text) VALUES ('".$_SESSION['ID']."','0','".$_POST['title']."','".$_POST['Text']."');");
	}else{
		mysql_query("INSERT INTO notes (ID, Entry, Title, Text) VALUES ('".$_SESSION['ID']."','".++$last['Entry']."','".$_POST['title']."','".$_POST['Text']."');");
	}
	Close($con);
	echo '<meta http-equiv="refresh" content="0;">';
}
?>
<form method="POST">
	<table class="Message">
		<tr>
			<th style="width:50px;">Title: </th><th><input type="text" name="title"></th>
		</tr>
		<tr>
			<th><input type="text" name="Text" style="width:320px;height:100px;"></th><th><input type="submit" value="Speichern"></th>
		</tr>
		<?php
			$con = Connect();
			$check = mysql_num_rows(mysql_query("SELECT * FROM notes WHERE ID LIKE '".$_SESSION['ID']."'"));
			if($check != 0)
			{
				//==>output entries
			}else{ echo '<tr style="border:1px solid #444444;"><th>No Entries found.</th></tr>'; }
			Close($con);
		?>
	</table>
</form>